package com.common.sort;

import java.util.Collections;
import java.util.List;

/**
 * @author 大忽悠
 * @create 2022/10/16 19:41
 */
public class SortUtil {
    /**
     * @param collections 待排序集合
     * @param nature 大于0是升序,小于等于0是降序
     * @param <T>
     * @return
     */
    public static <T extends Order> List<T> LIST_SORT(List<T> collections, int nature){
        Collections.sort(collections,(o1, o2)->{
            Order order1 = (Order) o1;
            Order order2 = (Order) o2;
            return nature>0?order1.getOrder()-order2.getOrder():order2.getOrder()-order1.getOrder();
        });
        return collections;
    }
}
